package com.design.chain;

/**
* Description: 责任链模式<br/>
* date: 2023/11/24 14:05<br/>
* @author: zhangzaijun <br/>
* @since JDK 1.8
*/

public class ChainMain {
    public static void main(String[] args) {
        AbstractLogger infoLogger = new InfoLogger(ChainEnum.INFO.getValue());
        AbstractLogger consoleLogger = new ConsoleLogger(ChainEnum.DEBUG.getValue());
        AbstractLogger errorLogger = new ErrorLogger(ChainEnum.ERROR.getValue());

        infoLogger.setNextLogger(consoleLogger);
        consoleLogger.setNextLogger(errorLogger);

        infoLogger.logMessage(ChainEnum.ERROR.getValue(), "info message");
        consoleLogger.logMessage(ChainEnum.ERROR.getValue(), "console message");
        errorLogger.logMessage(ChainEnum.ERROR.getValue(), "error message");
    }
}
